package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
@Api(value = "自媒体端素材管理相关接口",tags = "自媒体端素材管理相关接口")
public class WmMaterialController {


    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * 素材图片上传
     * @param multipartFile
     * @return
     */
    @PostMapping("/upload_picture")
    @ApiOperation("素材图片上传")
    public ResponseResult uploadPicture(MultipartFile multipartFile){
        return wmMaterialService.uploadPicture(multipartFile);
    }

    /**
     * 素材列表查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("素材列表查询")
    public ResponseResult findList(@RequestBody WmMaterialDto dto){
        return wmMaterialService.findList(dto);
    }

    /**
     * 素材图片删除
     * @param id
     * @return
     */
    @GetMapping("/del_picture/{id}")
    @ApiOperation("素材图片删除")
    public ResponseResult delPicture(@PathVariable Integer id){
        return wmMaterialService.delPicture(id);
    }

    /**
     * 收藏素材图片
     * @param id
     * @return
     */
    @GetMapping("/collect/{id}")
    @ApiOperation("收藏素材图片")
    public ResponseResult collectPicture(@PathVariable Integer id){
        return wmMaterialService.collectPicture(id);
    }

    /**
     * 取消收藏素材图片
     * @param id
     * @return
     */
    @GetMapping("/cancel_collect/{id}")
    @ApiOperation("取消收藏素材图片")
    public ResponseResult cancelCollectPicture(@PathVariable Integer id){
        return wmMaterialService.cancelCollectPicture(id);
    }
}
